import requests
import allure
import pymysql
import logging
import os

@allure.step("2.发送Http请求")
def send_http_request(**request_data):
    response = requests.request(**request_data)

    logging.info(f"2.发送HTTP请求, 响应文本为: {response.text}")
    return response

def send_jdbc_request(sql,index=0):
        conn = pymysql.connect(
            # host=DB_HOST,
            # port=DB_PORT,
            # database=DB_DATABASE,
            # user=DB_USER,
            # passwd=DB_PASSWORD,
            **(eval(os.environ["DB"])),
            charset="utf8"
        )
        cur = conn.cursor()
        cur.execute(sql)
        result = cur.fetchone()
        cur.close()
        conn.close()
        return  result[index]
